<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	积分、余额日志
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['params']['status']=0;
	$return['pluginset']['chou_paitypetitle']=$this->paitypes[$return['pluginset']['chou_paitype']];
	$return['choudesc']='有'.$return['pluginset']['chourate'].'%概率,抽中得剩余返额的相同金币！同时订单完成排队；未抽中返'.$return['pluginset']['chou_jifen'].'%积分,';
	if($return['pluginset']['chou_paitype']==3){
		$return['choudesc'] .='将直接退出排队！';
	}else{
		$return['choudesc'] .='进入排队['.$return['pluginset']['chou_paitypetitle'].']的资格！';
	}
	set_html('title','排单记录');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($_RQ['status']!=100){
		$params['status']=intval($_RQ['status']);
	}
	$return['params']=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$return['params']['psize']=$_RQ['psize'];
	}
	$psize = $_RQ['psize']?:10;
	//时间范围
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$list=$this->getslice('order',$params,array($pindex,$psize),$total,array(),'','id desc');
	$ti_feerate=$this->setting['ti_feerate']?:0;
	foreach($list as &$item){
		$item['member']=cfc('core')->member_show($item['mid']);
		$item['merchname']=pdo_getcolumn('jy_merch_user',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['merchid']),'merchname');
		$item['cantifee']=$item['jindu']*$item['price']/100;
		$item['lastcantifee']=price($item['cantifee']-$item['istifee'],'int');
		$item['choutifee']=price($ti_feerate*$item['lastcantifee']/100,'int');
		$lastprice=$item['price']-$item['cantifee'];
		if(!$item['status']){
			$item['tuifee1']=price($this->setting['pai_tuifee1']*$lastprice/100);
			$item['tuifee2']=price($this->setting['pai_tuifee2']*$lastprice/100);
			$item['tuifee3']=price($this->setting['pai_tuifee3']*$lastprice/100);
		}
		$item['statustitle']=$this->paiorderstatus[$item['status']];
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		if($item['ischou']==2){
			$item['chou_paitypetitle']=$this->paitypes[$item['chou_paitype']];
		}
		$item['cantifee']=price($item['cantifee']);
	}
	$return['list']=$list?$list:array();
	exi($return);
}
if($_RQ['op']=='tuifan'){
	$post=get_postdata();	
	$id=intval($post['id'])?:intval($_RQ['id']);
	if($id){
		$this->model('pai')->tuifan($id);
		exi('退出成功！','','/paiorder/');		
	}else{		
		exi('取消失败！','error');
	}

}
if($_RQ['op']=='tixian'){
	$post=get_postdata();	
	$id=intval($post['id'])?:intval($_RQ['id']);
	if($id){
		$this->model('pai')->tixian($id);
		exi('提现成功！','','/paiorder/');		
	}else{		
		exi('提现失败！','error');
	}

}
if($_RQ['op']=='checkchou'){
	$post=get_postdata();	
	$id=intval($post['id'])?:intval($_RQ['id']);
	if($id){
		$this->model('pai')->checkchou($id);
		exi('抽奖完成！','','/paiorder/');		
	}else{		
		exi('抽奖失败！','error');
	}

}